package com.teaboot.springbootsample.service;

import com.teaboot.springbootsample.dao.ProductDao;
import com.teaboot.springbootsample.domain.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductService {

    @Autowired
    private ProductDao productDao;


    public List getProducts(){
        return productDao.search();
    }

    public Product getProduct(Integer id){
        return productDao.selectByPrimaryKey(id);
    }

    public void addProduct(Product product){
        productDao.insert(product);
    }

    public void updateProduct(Product product){
        productDao.updateByPrimaryKey(product);
    }

    public void deleteProduct(Integer id){
        productDao.deleteByPrimaryKey(id);
    }

}
